class StockPrice
{
public:
    StockPrice()
    {
    }

    void update(int timestamp, int price)
    {
        if (timePrice.count(timestamp))
        {
            int oldPrice = timePrice[timestamp];
            priceTime[oldPrice].erase(timestamp);
            if (priceTime[oldPrice].empty())
            {
                priceTime.erase(oldPrice);
            }
        }

        timePrice[timestamp] = price;
        priceTime[price].insert(timestamp);
    }

    int current()
    {
        return timePrice.rbegin()->second;
    }

    int maximum()
    {
        return priceTime.rbegin()->first;
    }

    int minimum()
    {
        return priceTime.begin()->first;
    }

private:
    map<int, int> timePrice;
    map<int, unordered_set<int>> priceTime;
};

/**
 * Your StockPrice object will be instantiated and called as such:
 * StockPrice* obj = new StockPrice();
 * obj->update(timestamp,price);
 * int param_2 = obj->current();
 * int param_3 = obj->maximum();
 * int param_4 = obj->minimum();
 */